<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateUserLoginLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_login_logs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('userId')->default(0)->comment('用户id');
            $table->string('mobile',20)->default('')->comment('用户手机号');
            $table->string('userName',50)->default('')->comment('用户昵称');
            $table->unsignedTinyInteger('type')->default(1)->comment(' 类型 1：web 2：pos 3 小程序 4 商家app');
            $table->unsignedInteger('ip')->default(0)->comment('ip地址');
            $table->decimal('longitude', 10, 7)->default(0)->comment('经度');
            $table->decimal('latitude', 10, 7)->default(0)->comment('纬度');
            $table->string('serialNumber',100)->default('')->comment('设备序列号');
            $table->integer("createdAt")->default(0)->unsigned()->comment("创建时间");
            $table->integer("updatedAt")->default(0)->unsigned()->comment("更新时间");
            $table->index('mobile', 'idx_mobile');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '管理员登录日志表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_login_logs');
    }
}
